<?php
/**
 * Portfolio index
 *
 */

gatekeeper();

$title = elgg_echo('Portfolio');
$usr_id = elgg_get_logged_in_user_guid();

$options = array('type' => 'object', 
    						//'subtype' => '',
    						'owner_guid' => $usr_id, 
								'full_view' => false);
//print_r($vars['page']);
$func_tab_select = $vars['page'];
//$options['subtype'] = $func_tab_select;
switch ($func_tab_select) 
{
	case 'holding':
		$options['subtype'] = 'holding';
		$content = elgg_view('portfolio/holding');
		$sidebar = elgg_view('portfolio/sidebar/holding');
		break;
	case 'trade':
		$options['subtype'] = 'trade';
		$content = elgg_view('portfolio/trade');
		$sidebar = elgg_view('portfolio/sidebar/trade');
		break;
	case 'pnl':
		$options['subtype'] = 'pnl';
		$content = elgg_view('portfolio/pnl');
		$sidebar = elgg_view('portfolio/sidebar/pnl');
		break;
	case 'overview':
	default:
		$options['subtype'] = 'overview';
		$content = elgg_view('portfolio/overview');
		$sidebar = elgg_view('portfolio/sidebar/overview');
		break;
}

///daniel.lin 2012-8-21
/// for export to excel
$export = get_input("export");
if ($export == "Export to Excel") {
header("Content-type:application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition:filename={$func_tab_select}.xls");

echo $content;
exit;
}

$params = array(
	'title' => $title, 
	'content' => $content,
	'sidebar_alt' => $sidebar,
	'filter_override' => elgg_view('portfolio/func_tab', array('selected' => $func_tab_select)),
);

$body = elgg_view_layout('content', $params);
echo elgg_view_page($title, $body);
